package com.lmk.qs.dataSourse;



import com.lmk.qs.utils.JDBCUtil;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import com.mchange.v2.c3p0.impl.NewProxyResultSet;

import javax.sql.CommonDataSource;
import javax.sql.DataSource;
import java.sql.*;

public class c3p0 {


    public static void main(String[] args) throws SQLException {

        DataSource dc=null;
        Connection con=null;
        Statement statement=null;
        ResultSet rs= null;
        try {
            dc=new ComboPooledDataSource();

              con=dc.getConnection();

            String sql="select * from emp";
           statement=con.createStatement();
             rs= statement.executeQuery(sql);
            while (rs.next()){
                System.out.print("id" + "\t" + rs.getString(1));
                System.out.print("\t" +"name" + "\t" + rs.getString(2));
                System.out.print("\t" +"gender" + "\t" + rs.getString(3));
                System.out.print("\t" +"salary" + "\t" + rs.getString(4));
                System.out.print("\t" +"join_date" + "\t" + rs.getString(5));
                System.out.println("\t" +"dept_id" + "\t" + rs.getString(6));


            }








        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            JDBCUtil.close(rs,statement,con);
        }
    }



}
